import defaultSettings from './defaultSettings'; // https://umijs.org/config/

import slash from 'slash2';
import webpackPlugin from './plugin.config';
const { pwa, primaryColor } = defaultSettings; // preview.pro.ant.design only do not use in your production ;
// preview.pro.ant.design 专用环境变量，请不要在你的项目中使用它。
const fs = require('fs')
const path = require('path')

const getParentsName = () => {
  const isDir = /\.jsx|ejs|umi$/
  const fr = fs.readdirSync(path.join(__dirname, `../src/pages`))
  const res = []
  fr.map(d => !isDir.test(d) && d != 'user' && res.push(d))
  return res
}

const getComponents = () => {
  const isFile = /\.jsx$/
  const res = getParentsName().map(f => fs.readdirSync(path.join(__dirname, `../src/pages/${f}`)))
  const result = {} // 初始数据
  res.map((arr, i) => {
    result[getParentsName()[i]] = arr
  })
  for (let [key, value] of Object.entries(result)) {
    const files = value.filter(v => !isFile.test(v))
    value.map((v, i) => {
      if (isFile.test(v)) {
        // 替换数据
        value.splice(i, 1, `${key}/${v.replace(isFile, '')}`)
      } else {
        const r = fs.readdirSync(path.join(__dirname, `../src/pages/${key}/${v}`))
        r.map(f => {
          value.push(`${key}/${v}/${f.replace(isFile, '')}`)
        })
      }
    })
  }
  return formatData(result)
}

const formatData = (obj) => {
  for (let [key, val] of Object.entries(obj)) {
    const rou = []
    const children = []
    const c = val.filter(v => v.indexOf('/') != -1).map(p => {
      children.push({
        path: p,
        component: `./${p}`
      })
      return children
    })
    Object.keys(obj).map(k => {
      rou.push({
        path: k,
        routes: c
      })
    })

    return rou
    // console.log(JSON.stringify(rou))
  }
}

const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION } = process.env;
const isAntDesignProPreview = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site';
const plugins = [
  [
    'umi-plugin-react',
    {
      antd: true,
      dva: {
        hmr: true,
      },
      locale: {
        // default false
        enable: false,
        // default zh-CN
        default: 'zh-CN',
        // default true, when it is true, will use `navigator.language` overwrite default
        baseNavigator: true,
      },
      // dynamicImport: {
      //   loadingComponent: './components/PageLoading/index',
      //   webpackChunkName: true,
      //   level: 3,
      // },
      pwa: pwa
        ? {
            workboxPluginMode: 'InjectManifest',
            workboxOptions: {
              importWorkboxFrom: 'local',
            },
          }
        : false, // default close dll, because issue https://github.com/ant-design/ant-design-pro/issues/4665
      // dll features https://webpack.js.org/plugins/dll-plugin/
      // dll: {
      //   include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
      //   exclude: ['@babel/runtime', 'netlify-lambda'],
      // },
    },
  ],
  [
    'umi-plugin-pro-block',
    {
      moveMock: false,
      moveService: false,
      modifyRequest: true,
      autoAddMenu: true,
    },
  ],
]; // 针对 preview.pro.ant.design 的 GA 统计代码

// if (isAntDesignProPreview) {
//   plugins.push([
//     'umi-plugin-ga',
//     {
//       code: 'UA-72788897-6',
//     },
//   ]);
//   plugins.push([
//     'umi-plugin-pro',
//     {
//       serverUrl: 'https://ant-design-pro.netlify.com',
//     },
//   ]);
// }

export default {
  plugins,
  block: {
    // 国内用户可以使用码云
    // defaultGitUrl: 'https://gitee.com/ant-design/pro-blocks',
    defaultGitUrl: 'https://github.com/ant-design/pro-blocks',
  },
  hash: true,
  targets: {
    ie: 11,
  },
  devtool: isAntDesignProPreview ? 'source-map' : false,
  // umi routes: https://umijs.org/zh/guide/router.html
  routes: [
    {
      path: '/user',
      component: '../layouts/UserLayout',
      routes: [
        {
          name: 'login',
          path: '/user/login',
          component: './user/login',
        },
      ],
    },
    {
      path: '/',
      component: '../layouts/SecurityLayout',
      routes: [
        {
          path: '/',
          component: '../layouts/BasicLayout',
          routes: [
            {
              path: '/',
              redirect: '/index',
            },
            {
              path: '/index',
              component: './Welcome',
            },
            { // 分销中心
              path: '/distribution',
              routes: [{
                routes: [
                  {
                    path: '/distribution/setting/single',
                    component: './distribution/setting/single',
                  },
                  {
                    path: '/distribution/setting/membershipCard',
                    component: './distribution/setting/membershipCard',
                  },
                  {
                    path: '/distribution/setting/cashier',
                    component: './distribution/setting/cashier',
                  },
                  {
                    path: '/distribution/setting/base',
                    component: './distribution/setting/base',
                  },
                  {
                    path: '/distribution/setting/scheme',
                    component: './distribution/setting/scheme',
                  },
                  {
                    path: '/distribution/whole/cashier',
                    component: './distribution/whole/cashier',
                  },
                  {
                    path: '/distribution/whole/staff',
                    component: './distribution/whole/staff',
                  },
                  {
                    path: '/distribution/whole/vip',
                    component: './distribution/whole/vip',
                  },
                  {
                    path: '/distribution/commission/payroll',
                    component: './distribution/commission/payroll',
                  },
                  {
                    path: '/distribution/commission/cashManage',
                    component: './distribution/commission/cashManage',
                  },
                  {
                    path: '/distribution/commission/record',
                    component: './distribution/commission/record',
                  },
                  {
                    path: '/distribution/commission/Withdraw',
                    component: './distribution/commission/Withdraw',
                  },
                  {
                    path: '/distribution/commission/withdrawHistory',
                    component: './distribution/commission/withdrawHistory',
                  },
                  {
                    path: '/distribution/order',
                    component: './distribution/order',
                  },
                  {
                    path: '/distribution/orderDetails',
                    component: './distribution/orderDetails',
                  },
                  {
                    path: '/distribution/commissionPlace/withdrewManage',
                    component: './distribution/commissionPlace/withdrewManage',
                  },
                  {
                    path: '/distribution/commissionPlace/audit',
                    component: './distribution/commissionPlace/audit',
                  },
                  {
                    path: '/distribution/commissionPlace/bankCard',
                    component: './distribution/commissionPlace/bankCard',
                  },
                  {
                    path: '/distribution/report/storeStat',
                    component: './distribution/report/storeStat',
                  },
                  {
                    path: '/distribution/report/goodsStat',
                    component: './distribution/report/goodsStat',
                  },
                ]
              }]
            },
            {
              path: '/platform',
              routes: [
                {
                  path: '/platform/industry/industryList',
                  component: './platform/industry/industryList',
                },
                {
                  path: '/platform/check/store',
                  component: './platform/check/store',
                },
                {
                  path: '/platform/check/storeDetails',
                  component: './platform/check/storeDetails',
                },
                {
                  path: '/platform/check/agent',
                  component: './platform/check/agent',
                },
                {
                  path: '/platform/check/merchant',
                  component: './platform/check/merchant',
                },
              ]
            },
            {
              path: '/setting',
              routes: [
                {
                  // path: '/auth',
                  // exact: true,
                  routes: [
                    {
                      path: '/setting',
                      redirect: '/setting/auth/user',
                    },
                    {
                      path: '/setting/auth/user',
                      component: './setting/auth/auth',
                    },
                    {
                      path: '/setting/auth/role',
                      component: './setting/auth/role',
                    },
                    {
                      path: '/setting/auth/permission',
                      component: './setting/auth/permission',
                    },
                    {
                      path: '/setting/auth/menu',
                      component: './setting/auth/menu',
                    },
                    {
                      path: '/setting/auth/button',
                      component: './setting/auth/button',
                    },
                    {
                      path: '/setting/auth/operation',
                      component: './setting/auth/operation',
                    },
                    {
                      path: '/setting/auth/group',
                      component: './setting/auth/group',
                    },
                    {
                      path: '/setting/auth/members',
                      component: './setting/auth/members',
                    },
                    {
                      path: '/setting/auth/manages',
                      component: './setting/auth/manages',
                    },
                    {
                      path: '/setting/trans/freightTmp',
                      component: './setting/trans/freightTmp',
                    },
                    {
                      path: '/setting/trans/freightTmpDetail',
                      component: './setting/trans/freightTmpDetail',
                    },
                    {
                      path: '/setting/trans/compony',
                      component: './setting/trans/compony',
                    },
                    {
                      path: '/setting/trans/delivery',
                      component: './setting/trans/delivery',
                    },
                    {
                      path: '/setting/manage/app',
                      component: './setting/manage/app',
                    },
                    {
                      path: '/setting/manage/wx',
                      component: './setting/manage/wx',
                    },
                    {
                      path: '/setting/wechat/miniProgram',
                      component: './setting/wechat/miniProgram',
                    },
                    {
                      path: '/setting/wechat/officialAccount',
                      component: './setting/wechat/officialAccount',
                    },
                    {
                      path: '/setting/wechat/commercial',
                      component: './setting/wechat/commercial',
                    },
                    {
                      path: '/setting/trade/withdrew',
                      component: './setting/trade/withdrew',
                    },
                    {
                      path: '/setting/trade/tradeList',
                      component: './setting/trade/tradeList',
                    },
                    {
                      path: '/setting/trade/settings',
                      component: './setting/trade/settings',
                    },
                    {
                      path: '/setting/inv/invConfig',
                      component: './setting/inv/invConfig',
                    },
                    {
                      path: '/setting/inv/project',
                      component: './setting/inv/project',
                    },
                    {
                      path: '/setting/inv/invList',
                      component: './setting/inv/invList',
                    },
                    {
                      path: '/setting/inv/faultiness',
                      component: './setting/inv/faultiness',
                    },
                  ]
                },
              ]
            },
            // 租务中心
            {
              path: '/rentCenter',
              routes: [
                // 商铺列表
                {
                  path: '/rentCenter/basicSet/storeShopList',
                  component: './rentCenter/basicSet/storeShopList'
                },
                // 商铺确认
                {
                  path: '/rentCenter/basicSet/auditStoreShop',
                  component: './rentCenter/basicSet/auditStoreShop'
                },
                // 品牌管理
                {
                  path: '/rentCenter/basicSet/storeShopBrand',
                  component: './rentCenter/basicSet/storeShopBrand'
                },
                // 业态管理
                {
                  path: '/rentCenter/basicSet/storeShopFormats',
                  component: './rentCenter/basicSet/storeShopFormats'
                },
                // 商户管理
                {
                  path: '/rentCenter/investmentManagement/operatingSupplierManage',
                  component: './rentCenter/investmentManagement/operatingSupplierManage'
                },
                // 门店管理
                {
                  path: '/rentCenter/investmentManagement/operatingStoreManage',
                  component: './rentCenter/investmentManagement/operatingStoreManage'
                },
                // 合同类型
                {
                  path: '/rentCenter/contractManage/contractType',
                  component: './rentCenter/contractManage/contractType'
                },
                // 我的合同
                {
                  path: '/rentCenter/contractManage/myContract',
                  component: './rentCenter/contractManage/myContract'
                },
                // 添加我的合同
                {
                  path: '/rentCenter/contractManage/addMyContract',
                  component: './rentCenter/contractManage/addMyContract'
                },
                // 待审合同
                {
                  path: '/rentCenter/contractManage/pendingContract',
                  component: './rentCenter/contractManage/pendingContract'
                },
                // 待审合同详情
                {
                  path: '/rentCenter/contractManage/contractDetail',
                  component: './rentCenter/contractManage/contractDetail'
                },
                // 合同清单
                {
                  path: '/rentCenter/contractManage/contractListing',
                  component: './rentCenter/contractManage/contractListing'
                },
                // 款项类型
                {
                  path: '/rentCenter/collectionManage/collectionType',
                  component: './rentCenter/collectionManage/collectionType'
                },
                // 收款方式
                {
                  path: '/rentCenter/collectionManage/collectionWay',
                  component: './rentCenter/collectionManage/collectionWay'
                },
                // 收款维护
                {
                  path: '/rentCenter/collectionManage/receivingMaintenance',
                  component: './rentCenter/collectionManage/receivingMaintenance'
                },
                // 款项清单
                {
                  path: '/rentCenter/collectionManage/receivingListing',
                  component: './rentCenter/collectionManage/receivingListing'
                },
                // 交费提醒
                {
                  path: '/rentCenter/collectionManage/payToRemind',
                  component: './rentCenter/collectionManage/payToRemind'
                },
                // 员工管理
                {
                  path: '/rentCenter/acount_/acount_list',
                  component: './rentCenter/acount_/acount_list'
                },
              ]
            },
            // 商品中心
            {
              path: '/goodsCenter',
              routes: [
                {
                  path: '/goodsCenter/invoicingManage', // 进销存管理
                  routes: [
                    {
                      path: '/goodsCenter/invoicingManage/supplierManagement', // 供应商管理
                      component: './goodsCenter/invoicingManage/supplierManagement'
                    },
                    {
                      path: '/goodsCenter/invoicingManage/buyManage', // 进货管理
                      component: './goodsCenter/invoicingManage/buyManage'
                    },
                    {
                      path: '/goodsCenter/invoicingManage/buyOrReturn', // 采购退货
                      component: './goodsCenter/invoicingManage/buyOrReturn'
                    },
                    {
                      path: '/goodsCenter/invoicingManage/stockCheck', // 库存盘点
                      component: './goodsCenter/invoicingManage/stockCheck'
                    },
                    {
                      path: '/goodsCenter/invoicingManage/stockChange', // 库存调拨
                      component: './goodsCenter/invoicingManage/stockChange'
                    }
                  ]
                },
                {
                  path: '/goodsCenter/houseManage', // 台房管理
                  routes: [
                    {
                      path: '/goodsCenter/houseManage/floorManage', // 楼层管理
                      component: './goodsCenter/houseManage/floorManage'
                    },
                    {
                      path: '/goodsCenter/houseManage/roomType', // 台房类型
                      component: './goodsCenter/houseManage/roomType'
                    },
                    {
                      path: '/goodsCenter/houseManage/roomManage', // 台房管理
                      component: './goodsCenter/houseManage/roomManage'
                    },
                    {
                      path: '/goodsCenter/houseManage/roomPeriodManage', // 市别管理
                      component: './goodsCenter/houseManage/roomPeriodManage'
                    },
                    {
                      path: '/goodsCenter/houseManage/distrotionRoomManage', // 分销排班
                      component: './goodsCenter/houseManage/distrotionRoomManage'
                    },
                    {
                      path: '/goodsCenter/houseManage/roomSchedule', // 排班管理
                      component: './goodsCenter/houseManage/roomSchedule'
                    }
                  ]
                },
                {
                  path: '/goodsCenter/goodsManage', // 商品管理
                  routes: [
                    {
                      path: '/goodsCenter/goodsManage/addGroupGood', // 添加组合商品
                      component: './goodsCenter/goodsManage/addGroupGood'
                    },
                    {
                      path: '/goodsCenter/goodsManage/addGood', // 添加商品
                      component: './goodsCenter/goodsManage/addGood'
                    },
                    {
                      path: '/goodsCenter/goodsManage/distributionGoodsList', // 分销商品列表
                      component: './goodsCenter/goodsManage/distributionGoodsList'
                    },
                    {
                      path: '/goodsCenter/goodsManage/goodsList', // 商品列表
                      component: './goodsCenter/goodsManage/goodsList'
                    },
                    {
                      path: '/goodsCenter/goodsManage/goodsCat', // 商品分类
                      component: './goodsCenter/goodsManage/goodsCat'
                    },
                    {
                      path: '/goodsCenter/goodsManage/goodsNorm', // 规格管理
                      component: './goodsCenter/goodsManage/goodsNorm'
                    },
                    {
                      path: '/goodsCenter/goodsManage/goodsAttr', // 属性管理 6
                      component: './goodsCenter/goodsManage/goodsAttr'
                    },
                    {
                      path: '/goodsCenter/goodsManage/customerReviews', // 客户评价
                      component: './goodsCenter/goodsManage/customerReviews'
                    },
                    {
                      path: '/goodsCenter/goodsManage/goodsRecycle', // 商品回收站
                      component: './goodsCenter/goodsManage/goodsRecycle'
                    },
                    {
                      path: '/goodsCenter/goodsManage/addEvaluate', // 添加评论
                      component: './goodsCenter/goodsManage/addEvaluate'
                    },
                    {
                      path: '/goodsCenter/goodsManage/specification', // 规格列表
                      component: './goodsCenter/goodsManage/specification'
                    },
                    {
                      path: '/goodsCenter/goodsManage/attribute', // 属性列表
                      component: './goodsCenter/goodsManage/attribute'
                    },
                    {
                      path: '/goodsCenter/goodsManage/goodsBrand', // 品牌列表
                      component: './goodsCenter/goodsManage/goodsBrand'
                    },
                    {
                      path: '/goodsCenter/goodsManage/addGoodsBrand', // 添加品牌
                      component: './goodsCenter/goodsManage/addGoodsBrand'
                    }
                  ]
                }
              ]
            },
            // 商户中心
            {
              path: '/supplier',
              routes: [
                {
                  routes: [
                    {
                      path: '/supplier',
                      redirect: '/supplier/operator'
                    },
                    // 运营商管理
                    {
                      path: '/supplier/operator',
                      component: './supplier/operator'
                    },
                    // 新增运营商
                    {
                      path: '/supplier/addOperator',
                      component: './supplier/addOperator'
                    },
                    // 商户分销
                    {
                      path: '/supplier/distribution',
                      component: './supplier/distribution'
                    },
                    // 商户管理
                    {
                      path: '/supplier/manageOperator',
                      component: './supplier/manageOperator'
                    },
                    // 添加商户
                    {
                      path: '/supplier/addSupplier',
                      component: './supplier/addSupplier'
                    },
                    // 分类图标
                    {
                      path: '/supplier/category/iconType',
                      component: './supplier/category/iconType'
                    },
                    // 门店分类
                    {
                      path: '/supplier/category/storeType',
                      component: './supplier/category/storeType'
                    },
                    // 门店装修
                    {
                      path: '/supplier/store/decoration',
                      component: './supplier/store/decoration'
                    },
                    // 门店列表
                    {
                      path: '/supplier/store/storeList',
                      component: './supplier/store/storeList'
                    },
                    // 新增门店
                    {
                      path: '/supplier/store/addStore',
                      component: './supplier/store/addStore'
                    },
                    // 门店评价
                    {
                      path: '/supplier/store/storeComment',
                      component: './supplier/store/storeComment'
                    },
                    // POS管理
                    {
                      path: '/supplier/store/managePOS',
                      component: './supplier/store/managePOS'
                    },
                    // 新增POS
                    {
                      path: '/supplier/store/addPOS',
                      component: './supplier/store/addPOS'
                    },
                      // 待绑定门店列表
                    {
                      path: '/supplier/store/unBoundStore',
                      component: './supplier/store/unBoundStore'
                    },
                    // 基本信息
                    {
                      path: '/supplier/store/baseInfo',
                      component: './supplier/store/baseInfo'
                    },
                    // 员工管理
                    {
                      path: '/supplier/manageStaff/manageStaff',
                      component: './supplier/manageStaff/manageStaff'
                    },
                    // 部门管理
                    {
                      path: '/supplier/manageStaff/manageDepartment',
                      component: './supplier/manageStaff/manageDepartment'
                    },
                    // 分组管理
                    {
                      path: '/supplier/manageStaff/manageGroup',
                      component: './supplier/manageStaff/manageGroup'
                    },
                    // 员工管理
                    {
                      path: '/supplier/manageStaff/managePosition',
                      component: './supplier/manageStaff/managePosition'
                    },
                    // 店铺展示
                    {
                      path: '/supplier/store/storeShow',
                      component: './supplier/store/storeShow'
                    },
                    // 店铺分类
                    {
                      path: '/supplier/store/storeType',
                      component: './supplier/store/storeType'
                    },
                    // 店铺审核
                    {
                      path: '/supplier/store/storeAudit',
                      component: './supplier/store/storeAudit'
                    },
                    // 银行卡设置
                    {
                      path: '/supplier/withdraw/setCard',
                      component: './supplier/withdraw/setCard'
                    },
                    // 银行卡列表
                    {
                      path: '/supplier/withdraw/cardList',
                      component: './supplier/withdraw/cardList'
                    },
                    // 银行卡管理
                    {
                      path: '/supplier/withdraw/manageWithdraw',
                      component: './supplier/withdraw/manageWithdraw'
                    },
                    // 提现审核
                    {
                      path: '/supplier/withdraw/withdrawAudit',
                      component: './supplier/withdraw/withdrawAudit'
                    },
                    // 渠道商列表
                    {
                      path: '/supplier/distributor/list',
                      component: './supplier/distributor/list'
                    },
                    // 渠道商审核
                    {
                      path: '/supplier/distributor/audit',
                      component: './supplier/distributor/audit'
                    },
                    // 新增渠道商
                    {
                      path: '/supplier/distributor/add',
                      component: './supplier/distributor/add'
                    }
                  ]
                }
              ]
            },
            // 会员中心
            {
              path: '/userCenter',
              routes: [
                {
                  routes: [
                    {
                      path: '/userCenter',
                      redirect: '/userCenter/card/list'
                    },
                    // 会员卡列表
                    {
                      path: '/userCenter/card/list',
                      component: './userCenter/card/list'
                    },
                    // 卡操作记录
                    {
                      path: '/userCenter/card/handle',
                      component: './userCenter/card/handle'
                    },
                    // 全部会员
                    {
                      path: '/userCenter/userList/all',
                      component: './userCenter/userList/all'
                    },
                    // 微信会员
                    {
                      path: '/userCenter/userList/wx',
                      component: './userCenter/userList/wx'
                    },
                    // 人脸会员
                    {
                      path: '/userCenter/userList/face',
                      component: './userCenter/userList/face'
                    },
                    // 会员等级
                    {
                      path: '/userCenter/level',
                      component: './userCenter/level'
                    },
                    // 会员信息
                    {
                      path: '/userCenter/userList/info',
                      component: './userCenter/userList/info'
                    }
                  ]
                }
              ]
            },
            // 订单中心
            {
              path: '/order',
              routes: [
                {
                  routes: [
                    {
                      path: '/order',
                      redirect: '/order/online'
                    },
                    // 线上订单
                    {
                      path: '/order/online',
                      component: './order/online'
                    },
                    // 线下订单
                    {
                      path: '/order/offline',
                      component: './order/offline'
                    },
                    // 售后订单
                    {
                      path: '/order/afterSale',
                      component: './order/afterSale'
                    },
                    // 售后退款
                    {
                      path: '/order/refund',
                      component: './order/refund'
                    },
                    // 预约订单
                    {
                      path: '/order/presell',
                      component: './order/presell'
                    },
                    // 订单详情
                    {
                      path: '/order/orderDetail',
                      component: './order/orderDetail'
                    }
                  ]
                }
              ]
            },
            // 数据中心
            {
              path: '/dataCenter',
              routes: [
                {
                  routes: [
                    // 客流数据 > MAC 配置
                    {
                      path: '/dataCenter/customerData/macConfig',
                      component: './dataCenter/customerData/macConfig'
                    },
                    // 客流数据 > 到访记录
                    {
                      path: '/dataCenter/customerData/visitRecord',
                      component: './dataCenter/customerData/visitRecord'
                    },
                    // 客流数据 > 客流分析 Analysis
                    {
                      path: '/dataCenter/customerData/customerAnalysis',
                      component: './dataCenter/customerData/customerAnalysis'
                    },
                    // 营销收据 > 卡券报表
                    {
                      path: '/dataCenter/marketingData/cardDataForm',
                      component: './dataCenter/marketingData/cardDataForm'
                    },
                    // 财务数据 > 品牌统计报表
                    {
                      path: '/dataCenter/financeData/brandStatistics',
                      component: './dataCenter/financeData/brandStatistics'
                    },
                    // 财务数据 > 品牌销售明细
                    {
                      path: '/dataCenter/financeData/brandSaleDetail',
                      component: './dataCenter/financeData/brandSaleDetail'
                    },
                    // 财务数据 > 结算单查询
                    {
                      path: '/dataCenter/financeData/settleSheetQuery',
                      component: './dataCenter/financeData/settleSheetQuery'
                    },
                    // 财务数据 > 结算账号
                    {
                      path: '/dataCenter/financeData/settleAccount',
                      component: './dataCenter/financeData/settleAccount'
                    },
                    // 财务数据 > 财务报表
                    {
                      path: '/dataCenter/financeData/financialReports',
                      component: './dataCenter/financeData/financialReports'
                    },
                    // 财务数据 > 费率清算
                    {
                      path: '/dataCenter/financeData/RateSettle',
                      component: './dataCenter/financeData/RateSettle'
                    },
                    // 财务数据 > 对账单
                    {
                      path: '/dataCenter/financeData/accountStatement',
                      component: './dataCenter/financeData/accountStatement'
                    },
                    // 销售数据 > 老板通
                    {
                      path: '/dataCenter/salesData/bossPass',
                      component: './dataCenter/salesData/bossPass'
                    },
                    // 销售数据 > 商品统计
                    {
                      path: '/dataCenter/salesData/goodsStatistics',
                      component: './dataCenter/salesData/goodsStatistics'
                    },
                    // 代理数据 > 门店数据
                    {
                      path: '/dataCenter/proxyData/StoreData',
                      component: './dataCenter/proxyData/StoreData'
                    },
                    // 代理数据 > 会员数据
                    {
                      path: '/dataCenter/proxyData/memberData',
                      component: './dataCenter/proxyData/memberData'
                    },
                    // 代理数据 > 加盟数据
                    {
                      path: '/dataCenter/proxyData/leagueData',
                      component: './dataCenter/proxyData/leagueData'
                    },
                  ]
                }
              ]
            },
            // 营销中心
            {
              path: '/marketCenter',
              routes: [
                {
                  routes: [
                    // 秒杀抢购 > 秒杀列表
                    {
                      path: '/marketCenter/seckillBuy/seckillGoodsList',
                      component: './marketCenter/seckillBuy/seckillGoodsList'
                    },
                    // 秒杀抢购 > 添加/编辑 秒杀
                    {
                      path: '/marketCenter/seckillBuy/seckillGoodsConfig',
                      component: './marketCenter/seckillBuy/seckillGoodsConfig'
                    },
                    // 会员卡 > 会员卡设置
                    {
                      path: '/marketCenter/memberCard/memberCardSetting',
                      component: './marketCenter/memberCard/memberCardSetting'
                    },
                    // 短信营销 > 短信模板
                    {
                      path: '/marketCenter/SMS/SMStemplate',
                      component: './marketCenter/SMS/SMStemplate'
                    },
                    // 短信营销 > 短信配置
                    {
                      path: '/marketCenter/SMS/SMSconfig',
                      component: './marketCenter/SMS/SMSconfig'
                    },
                    // 优惠买单
                    {
                      path: '/marketCenter/discountBill',
                      component: './marketCenter/discountBill'
                    },
                    // 游戏市场
                    {
                      path: '/marketCenter/gameMarket',
                      component: './marketCenter/gameMarket'
                    },
                    // 积分设置
                    {
                      path: '/marketCenter/integralSet',
                      component: './marketCenter/integralSet'
                    },
                    // 卡券营销 > 满额赠券
                    {
                      path: '/marketCenter/coupon/activitiesList',
                      component: './marketCenter/coupon/activitiesList'
                    },
                    // 卡券营销 > 优惠券分类
                    {
                      path: '/marketCenter/coupon/couponClassify',
                      component: './marketCenter/coupon/couponClassify'
                    },
                    // 卡券营销 > 优惠券管理
                    {
                      path: '/marketCenter/coupon/couponManage',
                      component: './marketCenter/coupon/couponManage'
                    },
                    // 卡券营销 > 新增优惠券
                    {
                      path: '/marketCenter/coupon/addCoupon',
                      component: './marketCenter/coupon/addCoupon'
                    },
                    // 卡券营销 > 发送优惠券
                    {
                      path: '/marketCenter/coupon/sendCoupon',
                      component: './marketCenter/coupon/sendCoupon'
                    },
                    // 卡券营销 > 限时则扣
                    {
                      path: '/marketCenter/coupon/discount',
                      component: './marketCenter/coupon/discount'
                    },
                    // 互动营销 > 红包营销
                    {
                      path: '/marketCenter/interaction/redPacket',
                      component: './marketCenter/interaction/redPacket'
                    },
                    // 红包设置 > 基础设置nbCard
                    {
                      path: '/marketCenter/redPacketSetting/baseSetting',
                      component: './marketCenter/redPacketSetting/baseSetting'
                    },
                    // 红包设置 > N倍卡
                    {
                      path: '/marketCenter/redPacketSetting/nbCard',
                      component: './marketCenter/redPacketSetting/nbCard'
                    },
                    // 红包设置 > 红包任务
                    {
                      path: '/marketCenter/redPacketSetting/redPacketTask',
                      component: './marketCenter/redPacketSetting/redPacketTask'
                    },
                  ]
                }
              ]
            },
            // 运营中心 Operation center
            {
              path: '/operationCenter',
              routes: [
                {
                  routes: [
                    // 直播管理 > 直播间管理
                    {
                      path: '/operationCenter/liveManage/liveRoomConfig',
                      component: './operationCenter/liveManage/liveRoomConfig'
                    },
                    // 运营设置 > 标签设置
                    {
                      path: '/operationCenter/operaSetting/tagsConfig',
                      component: './operationCenter/operaSetting/tagsConfig'
                    },
                    // 广告设置 > 广告设置
                    {
                      path: '/operationCenter/ADmanage/ADmanage',
                      component: './operationCenter/ADmanage/ADmanage'
                    },
                    // 广告设置 > 广告位设置
                    {
                      path: '/operationCenter/ADmanage/ADposiManage',
                      component: './operationCenter/ADmanage/ADposiManage'
                    },
                    // 广告设置 > 添加广告
                    {
                      path: '/operationCenter/ADmanage/addAd',
                      component: './operationCenter/ADmanage/addAd'
                    },
                    // 广告设置 > 添加广告位
                    {
                      path: '/operationCenter/ADmanage/addAdPosi',
                      component: './operationCenter/ADmanage/addAdPosi'
                    },
                    // 运营管理 > 推送优惠券
                    {
                      path: '/operationCenter/operationManage/pushCoupons',
                      component: './operationCenter/operationManage/pushCoupons'
                    },
                    // 运营管理 > 素材管理
                    {
                      path: '/operationCenter/operationManage/sourceMaterial',
                      component: './operationCenter/operationManage/sourceMaterial'
                    },
                    // 运营管理 > 店员速发
                    {
                      path: '/operationCenter/operationManage/clerkSF',
                      component: './operationCenter/operationManage/clerkSF'
                    },
                    // 自动运营 > 自动运营
                    {
                      path: '/operationCenter/autoOperat/autoOperat',
                      component: './operationCenter/autoOperat/autoOperat'
                    },
                    // 店铺管理 > 推荐店铺
                    {
                      path: '/operationCenter/storeManage/recommendStore',
                      component: './operationCenter/storeManage/recommendStore'
                    },
                    // 店铺管理 > 置顶店铺
                    {
                      path: '/operationCenter/storeManage/topStore',
                      component: './operationCenter/storeManage/topStore'
                    },
                    // 咨询管理 > 咨询分类
                    {
                      path: '/operationCenter/info/infoClassify',
                      component: './operationCenter/info/infoClassify'
                    },
                    // 咨询管理 > 咨询管理
                    {
                      path: '/operationCenter/info/infoManage',
                      component: './operationCenter/info/infoManage'
                    },
                  ]
                }
              ]
            },
            {
              component: './404',
            },
            {
              component: './403',
            },
          ],
        },
        {
          component: './404',
        },
        {
          component: './403',
        },
      ],
    },
    {
      component: './404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    'primary-color': primaryColor,
  },
  define: {
    ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: ''
      // ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '', // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量，请不要在你的项目中使用它。
  },
  ignoreMomentLocale: true,
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
  disableRedirectHoist: true,
  cssLoaderOptions: {
    modules: true,
    getLocalIdent: (context, _, localName) => {
      if (
        context.resourcePath.includes('node_modules') ||
        context.resourcePath.includes('ant.design.pro.less') ||
        context.resourcePath.includes('global.less')
      ) {
        return localName;
      }

      const match = context.resourcePath.match(/src(.*)/);

      if (match && match[1]) {
        const antdProPath = match[1].replace('.less', '');
        const arr = slash(antdProPath)
          .split('/')
          .map(a => a.replace(/([A-Z])/g, '-$1'))
          .map(a => a.toLowerCase());
        return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
      }

      return localName;
    },
  },
  manifest: {
    basePath: '/',
  },
  chainWebpack: webpackPlugin,
  proxy: {
    '/Amaidan-Distribution-Web': {
      target: 'http://192.168.3.207/',
      changeOrigin: true,
      pathRewrite: { '': '' },
    },
    '/Amaidan-Goods-Web': {
      target: 'http://192.168.3.207/',
      changeOrigin: true,
      pathRewrite: { '': '' },
    },
    '/amaidan-sys-user': {
      target: 'http://192.168.3.207/',
      changeOrigin: true,
      pathRewrite: { '': '' },
    },
    '/Amaidan-Live-Web': {
      target: 'http://192.168.3.207/',
      changeOrigin: true,
      pathRewrite: { '': '' },
    },
    '/Amaidan-Market-Web': {
      target: 'http://192.168.3.207/',
      changeOrigin: true,
      pathRewrite: { '': '' },
    },
    '/Amaidan-Order-Web': {
      target: 'http://192.168.3.207/',
      changeOrigin: true,
      pathRewrite: { '': '' },
    },
    '/Amaidan-Wx-Web': {
      target: 'http://192.168.3.207/',
      changeOrigin: true,
      pathRewrite: { '': '' },
    },
    '/Amaidan-Center-Web': {
      target: 'http://192.168.3.207/',
      changeOrigin: true,
      pathRewrite: { '': '' },
    },
    '/amaidan-web-pc': {
      target: 'http://192.168.3.207/',
      changeOrigin: true,
      pathRewrite: { '': '' },
    },
    '/Amaidan-Merchants-Web': {
      target: 'http://192.168.3.207/',
      changeOrigin: true,
      pathRewrite: { '': '' },
    },
    '/Amaidan-Users-Web': {
      target: 'http://192.168.3.207/',
      changeOrigin: true,
      pathRewrite: { '': '' },
    },
  },
};
